package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("ajax")
public class AjaxController {

    @RequestMapping("/checkName")
    public String checkName(String name){
        if("java".equals(name)){
            return "no";
        }else {
            return "ok";
        }
    }

    @RequestMapping("/getUser")
    public UserBean getUser(){
        return new UserBean(1,"tom","13544468554", LocalDate.parse("1995-05-05"));
    }

    @RequestMapping("/findAll")
    public List<UserBean> getList(){
        return Arrays.asList(
                new UserBean(1,"tom","13544468554", LocalDate.parse("1995-05-05")),
                new UserBean(2,"rose","13544411111", LocalDate.parse("1992-10-05")),
                new UserBean(3,"jack","13523225458", LocalDate.parse("1985-10-26")));
    }
}
